<template>
	<view class="content">
		<!-- #ifndef MP-WEIXIN -->
		<u-navbar leftIcon="arrow-left" :title="title" bgColor="#fff" leftIconColor="#000"
			:fixed="true" :titleStyle="titleStyle" @leftClick="clickLeft" >
			<view slot="right">
				<text style="padding: 5px 16px;border-radius: 12px;background: #45C4B0;font-size: 10px;color: #fff;" @click="submit">完成</text>
			</view>
		</u-navbar>
		<!-- #endif -->
		<view class="tips_box2 display-flex" v-if="form.is_w== 0 && id && id != 6 && (!form.type_class || form.type_class == '0' || form.type_class == '')">
			<text class="tip_cont">您的橱窗因平台规则调整不可继续使用，请尽快调整或补齐相关内容，以确保符合平台的规定和要求。感谢您的理解与支持！</text>
		</view>
		<view class="tips_box display-flex" v-else-if="!form.is_w">
			<text class="tip_cont">根据平台规定，请仔细阅读《写手违规管理办法》，请勿发表违反平台规定的内容。</text>
			<text class="tip_btn" @tap="show2=true">立即查看</text>
		</view>
		<view class="tips_box2 display-flex" v-else-if="form.is_w">
			<text class="tip_cont">您的橱窗因存在违规或其他原因被平台暂时下架处理，请尽快调整违规内容，以确保符合平台的规定和要求。感谢您的理解与支持！</text>
		</view>
		
		<view class="baibox">
			<view class="baili" @click="setdata(0)">
				<view class="left">
					<view class="title">
						橱窗名称
						<span>*</span>
					</view>
				</view>
				<view class="cenbox">
					<scroll-view scroll-x="true" class="qianbox" style="font-size: 14px;color: #3D3D3D;">
						{{form.title?form.title:'请输入'}}
					</scroll-view>
				</view>
				<image :src="'/images/rarr.png' | formatImgUrl" class="rarr" mode=""></image>
			</view>

			<view class="baili other_wrap">
				<view class="item">
					<view class="left">
						<view class="title">
							类型设置
							<span>*</span>
						</view>
					</view>
					<view class="other">
						{{form.type_name}}
					</view>
				</view>
				<view class="bottom">
					<input type="text" disabled class="other_ipt" value="" placeholder="除其他类型外，每个类型的橱窗可上传一条"/>
				</view>
			</view>
			<!-- <view class="baili other_wrap" v-if="class_type==7||form.type==7" @click="$go('/showcase/tip/tip_list')"> -->
			<view class="baili other_wrap" @click="isChanged=true,$go('/showcase/tip/tip_list_new?id=' + class_type)" v-if="form.type_name != '其他'">
				<view class="item">
					<view class="left">
						<view class="title">
							标签匹配
							<span>*</span>
						</view>
					</view>

					<view class="cenbox">
						<scroll-view scroll-x="true" class="qianbox" style="font-size: 14px;color: #3D3D3D;"
							:style="form.type_class!='' && form.type_class != 0?'color:#45C4B0':''">
							{{form.type_class && form.type_class != 0?'已选择':'请选择'}}
						</scroll-view>
					</view>
					<image :src="'/images/rarr.png' | formatImgUrl" class="rarr" mode=""></image>
				</view>
				<view class="bottom">
					<input type="text" disabled class="other_ipt" value="" placeholder="当用户标签匹配时展示给用户" />
				</view>
			</view>

			<view class="baili" @click="setdata(1)">
				<view class="left">
					<view class="title">
						详细介绍
						<span>*</span>
					</view>
				</view>
				<view class="cenbox">
					<scroll-view scroll-x="true" class="qianbox" style="font-size: 14px;color: #3D3D3D;">
						{{form.desc && form.desc.length > 7 ?form.desc.substring(0,7) + '...' : (form.desc ? form.desc :'请输入')}}
					</scroll-view>
				</view>
				<image :src="'/images/rarr.png' | formatImgUrl" class="rarr" mode=""></image>
			</view>
			<view class="baili"  @click="showFee = true">
				<view class="left">
					<view class="title">
						费用标准
						<span>*</span>
					</view>
				</view>
				<view class="cenbox">
					<scroll-view scroll-x="true" class="qianbox" style="font-size: 14px;color: #3D3D3D;">
					
						{{form.price? Number(form.price) + "币/"+form.word_count:'请选择'}}
					</scroll-view>
				</view>
				<image :src="'/images/rarr.png' | formatImgUrl" class="rarr" mode=""></image>
			</view>
			<!-- <view class="baili" @click="setdata(2)">
				<view class="left">
					<view class="title">
						价格设置
						<span>*</span>
					</view>
				</view>
				<view class="cenbox">
					<scroll-view scroll-x="true" class="qianbox" style="font-size: 14px;color: #3D3D3D;">
						{{form.price? Number(form.price).toFixed(0) + '元':'请输入'}}
					</scroll-view>
				</view>
				<image :src="'/images/rarr.png' | formatImgUrl" class="rarr" mode=""></image>
			</view>
			<view class="baili" @click="setdata(3)">
				<view class="left">
					<view class="title">
						字数设置
						<span>*</span>
					</view>
				</view>
				<view class="cenbox">
					<scroll-view scroll-x="true" class="qianbox" style="font-size: 14px;color: #3D3D3D;">
						{{form.word_count}}
					</scroll-view>
				</view>
				<image :src="'/images/rarr.png' | formatImgUrl" class="rarr" mode=""></image>
			</view> -->
			<view class="baili" @click="showPiece=true">
				<view class="left">
					<view class="title">
						起拍单数
						<span>*</span>
					</view>
				</view>
				<view class="cenbox">
					<scroll-view scroll-x="true" class="qianbox" style="font-size: 14px;color: #3D3D3D;">

						{{form.start_shooting?form.start_shooting:'请输入'}}
					</scroll-view>
				</view>
				<image :src="'/images/rarr.png' | formatImgUrl" class="rarr" mode=""></image>
			</view>

			<!-- 10.16新增 -->
			<view class="baili other_wrap" v-if="form.type_name == '法律文书'">
				<view class="item display-flex just-between" style="margin-bottom: 20rpx;">
					<view class="left">
						<view class="title">
							资质认证
							<span>*</span>
						</view>
					</view>
				</view>
				<view class="img_bottom">
					<view class="imgView">
						<!-- <view v-for="(img,index) in form.flair" class="imgList">
							<image :src="img | formatImgUrl" mode="aspectFill"
								@click="$common.previewImage(img,form.flair)" style="width: 156rpx;height: 156rpx;">
							</image>
							
							<image :src="'/images/closeicon_g.png' | formatImgUrl" mode="aspectFill" v-if="is_up==0" class="imgClose" @click="deletePic2(index)">
							</image>
						</view>
						<view class="imgList">
							<image :src="'/images/up.png' | formatImgUrl" mode="widthFix"
								style="width: 156rpx;height: 156rpx;" @click="onChooseImg2"
								v-if="form.flair&&form.flair.length < 4"></image>
						</view> -->
						
						<u-upload ref="uUpload" :uploadIcon="'/images/up.png' | formatImgUrl" :multiple="true" maxCount="4" width="78" height="78" :action="uploadImgUrl" :fileList="form.flair" @afterRead='afterRead2' @delete="deletePic2">
						</u-upload>
					</view>

				</view>

				<view class="tip">
					此认证仅用于资质审核，任何完成认证后不会展示给用户
				</view>

			</view>

			<view class="baili other_wrap">
				<view class="item display-flex just-between" style="margin-bottom: 20rpx;">
					<view class="left">
						<view class="title">
							橱窗展示图片
							<span>*</span>
							<!-- <span class="lw">
								（请上传四张例文）
							</span> -->
						</view>
					</view>
					<image :src="'/images/helpicon.png' | formatImgUrl" mode="aspectFit" @tap="show1=true"
						style="width: 36rpx;height: 36rpx;"></image>
				</view>
				<view class="img_bottom">
					<view class="imgView">
						<!-- <view v-for="(img,index) in form.img" class="imgList">
							<image :src="img | formatImgUrl" mode="aspectFill"
								@click="$common.previewImage(img,form.img)" style="width: 156rpx;height: 156rpx;">
							</image>
							
							<image :src="'/images/closeicon_g.png' | formatImgUrl" mode="aspectFill" v-if="is_up==0" class="imgClose" @click="deletePic(index)">
							</image>
						</view>
						<view class="imgList">
							<image :src="'/images/up.png' | formatImgUrl" mode="widthFix"
								style="width: 156rpx;height: 156rpx;" @click="onChooseImg"
								v-if="form.img&&form.img.length < 4"></image>
						</view> -->
						
						<!-- <u-upload ref="uUpload" :uploadIcon="'/images/up2.png' | formatImgUrl" :multiple="false" maxCount="1" width="78" height="78" :action="uploadImgUrl" :fileList="form.fullImg" @afterRead='afterRead3' @delete="deletePic3">
						</u-upload> -->
						<u-upload ref="uUpload" :uploadIcon="'/images/up.png' | formatImgUrl" :multiple="true" maxCount="4" width="75" height="75" :action="uploadImgUrl" :fileList="form.img" @afterRead='afterRead' @delete="deletePic">
						</u-upload>
					</view>

				</view>

				<view class="tip" v-if="form.is_w == 0">
					上传例文需符合平台要求，详细请点击右侧图标查看
				</view>
				<view class="tip" style="color: #ED3232;" v-if="form.is_w == 1">
					{{form.refuse_msg}}
				</view>
			</view>
		</view>

		<!-- <view class="ti" @click="submit(true)">
			完成
		</view> -->

		<u-popup :show="show" mode="center">
			<view class="mask">

				<view class="jatitle" v-if="type==0">
					橱窗名称设置
				</view>
				<input v-if="type==0" type="text" class="japut" maxlength="20" placeholder="请输入橱窗名称" v-model="form.title">


				<view class="jatitle" v-if="type==1">
					详细介绍
				</view>
				<!-- 	<input v-if="type==1" type="digit" maxlength="200" class="japut" placeholder="请输入详细介绍"
					>	 -->

				<textarea v-if="type==1" v-model="form.desc" placeholder="请输入详细介绍" cols="30" rows="10"
					maxlength="200"></textarea>

				<view class="jatitle" v-if="type==2">
					价格设置
				</view>
				<input v-if="type==2" maxlength="6" type="number" class="japut" placeholder="请输入价格设置"
					v-model="form.price" @blur="checkContent">

				<!-- 	<view class="jatitle" v-if="type==0">
					价格设置
				</view>
				<input v-if="type==0" type="digit" class="japut" placeholder="请输入价格(元)"
					v-model="userInfo.writer_user_config.word_price"> -->


				<view class="jatitle" v-if="type==3">
					字数设置
				</view>
				<picker v-if="type==3" class="japut" @change="bindPickerChange" :value="index" :range="array">
					{{form.word_count}}
				</picker>


				<view class="jatitle" v-if="type==4">
					起拍单数
				</view>
				<input v-if="type==4" maxlength="6" type="number" class="japut" placeholder="请输入起拍单数"
					v-model="form.start_shooting">

				<view class="qubox">
					<view class="quli" @click="show = false">
						取消
					</view>
					<view class="que" @click="setting">
						确定
					</view>
				</view>

			</view>
		</u-popup>

		<!-- 认证须知 -->
		<u-popup :show="show2" mode="center" @close="close" @open="open">
			<view class="biaoqian">
				<view class="top">
					<image :src="userInfo.pic | formatImgUrl" mode=""></image>
					<view class="top_username">{{userInfo.username}}</view>
					<view class="createbtn">认证须知</view>
				</view>
				<view class="tab">
					橱窗名称：请填写本橱窗相关功能等信息。<br>
					标签设置：选择擅长的标签，点击“增加标签”可增加标签库中没有的标签。
				</view>
				<scroll-view scroll-y="true" class="scroll">
					橱窗名称：请填写本橱窗相关功能等信息。<br><br>
					标签匹配：选择擅长的标签，点击“增加标签”可增加标签库中没有的标签。<br><br>
					详细介绍：详细介绍本橱窗功能、类型等信息。<br><br>
					价格设置：请依据自身写作能力设置真实价格。<br><br>
					字数设置：请依据自身写作能力设置。<br><br>
					起拍单数：向本橱窗下单的最低数量，请依据自身需求设置。<br><br>
					例文展示：上传例文需与本橱窗名称及详细介绍的内容相关联。须为原创作品，不得抄袭、盗用他人作品，不得侵犯他人的知识产权。如发现您上传的对外展示例文存在违规行为，我们有权立即删除相关内容，并对您的账号进行限制或封禁处理。<br><br>
					
					认证通过后，可自由修改橱窗内容。平台采用先发后审制度，设置内所有内容均需遵守国家法律法规和平台相关规定，不得包含任何违法、违规、低俗、虚假等内容。不得包含任何外部链接、外部平台名称、二维码、联系方式等引流信息，不得引导用户前往其他平台或网站。

					<view class="white_mask">

					</view>
				</scroll-view>

				<image class="cl1" @click="show2=false" :src="'/images/cl1.png' | formatImgUrl" mode=""></image>
			</view>
		</u-popup>

		<!-- 查看协议 -->
		<u-popup :show="show1" mode="center" @close="close" @open="open">
			<view class="biaoqian">
				<view class="top">
					<image :src="userInfo.pic | formatImgUrl" mode=""></image>
					<view class="top_username">{{userInfo.username}}</view>
					<view class="createbtn">创建橱窗</view>
				</view>
				<view class="tab">
					欢迎您使用本平台的写手橱窗服务，为了维护平台的正常运营秩序，保障用户的合法权益，我们在此提醒您遵守以下协议：
				</view>
				<scroll-view scroll-y="true" class="scroll">
					例文展示须知<br><br>
					1.您在写手橱窗上传的对外展示例文必须遵守国家法律法规和平台相关规定，不得包含任何违法、违规、低俗、虚假等内容。<br>
					2.您在写手橱窗上传的对外展示例文不得包含任何外部链接、二维码、联系方式等引流信息，不得引导用户前往其他平台或网站。<br>
					3.您在写手橱窗上传的对外展示例文必须为原创作品，不得抄袭、盗用他人作品，不得侵犯他人的知识产权。<br>
					4.如发现您在写手橱窗上传的对外展示例文存在违规行为，我们有权立即删除相关内容，并对您的账号进行限制或封禁处理。<br><br>
					请您遵守以上协议，如有疑问或建议，请随时联系我们的客服人员。我们将不断优化服务，为您提供更好的使用体验。
					<view class="white_mask">

					</view>
				</scroll-view>

				<view class="cont_t" :class="[{'cont_t_gray': isAgree}]">
					<view class="t1" @click="show1=false">
						<view class="tex">
							我同意以上内容
						</view>
					</view>
				</view>

				<image class="cl1" @click="show1=false" :src="'/images/cl1.png' | formatImgUrl" mode=""></image>
			</view>
		</u-popup>
		
		<u-popup mode="center" :show="showConfirm" @close="showConfirm=false">
			<view class="mask" style="padding-left: 0;padding-right: 0;padding-bottom: 0;">
				<view class="matitle">
					<text>是否确认退出</text>
				</view>
				<view class="matxt">
					已填写的内容还没有保存
				</view>
				<view class="quque">
					<view class="quli" @click="showConfirm = false">
						取消
					</view>
					<view class="quli quactive" @click="$back">
						确定
					</view>
				</view>
			</view>
		</u-popup>
		
		<u-popup :show="showFee" mode="bottom" @close="showFee=false">
			<view class="custom-bot2">
				<view class="title">
					{{type_name ? type_name+'-' : ''}} 费用标准
				</view>
				<view class="display-flex show-box">
					<view class="inp-box display-flex">
						<text>最低稿价</text>
						<input type="number" placeholder="0" v-model="form.price" @input='checkNumber'/>
						<text>币</text>
					</view>
					<picker-view :value="fees" @change="changeFee" class="picker-view">
						<picker-view-column>
							<view class="item" v-for="(item,index) in array" :key="index">每{{item}}</view>
						</picker-view-column>
					</picker-view>
				</view>
		
				<view class="marginBorder"></view>
				<view class="btn" @tap="confirmSelect">
					确认选择
				</view>
			</view>
		</u-popup>
		
		<u-popup :show="showPiece" mode="bottom" @close="showPiece=false">
			<view class="custom-bot">
				<view class="title">
					起拍单数
				</view>
				<picker-view :value="dan" @change="changePiece" class="picker-view">
					<picker-view-column>
						<view class="item" v-for="(item,index) in pieces" :key="index">{{item}}单</view>
					</picker-view-column>
				</picker-view>
		
				<view class="marginBorder"></view>
				<view class="btn" @tap="showPiece=false,form.start_shooting=pieces[dan[0]]">
					确认选择
				</view>
			</view>
		</u-popup>
	</view>
</template>
<script>
	import * as db from '@/common/db.js'
	export default {
		data() {
			return {
				showPiece: false,
				showFee: false,
				dan: [0],
				fees: [0],
				type: 0,
				// 字数
				array: this.$db.get('config').word_count_label,
				index: 2,
				// 开关
				value: false,
				// 弹框
				show: false,
				userInfo: {},
				//苹果X以上手机底部适配高度
				paddingBottomHeight: 0,
				form: {
					id: '',
					title: '',
					desc: "",
					row_type: this.$db.get('config').tags.Xslx[0].id,
					price: '',
					word_count: this.$db.get('config').word_count_label[2],
					start_shooting: '',
					img: [],
					tags: '',
					type_class: '',
					flair: [] ,//资质认证图片
					fullImg: []
				},
				class_type: 0,
				type_name: "",
				is_up: 0,
				userInfo: this.$db.get('userInfo'),
				show1: false,
				show2: false,
				isAgree: true,
				fileList2: [],
				fileList3: [],
				fileList4: [],
				titleStyle: {
					color: '#000'
				},
				title: '',
				showConfirm: false,
				isChanged: false,
				pieces: [],
				config: {}
			}
		},
		created() {
			let that = this;
			uni.getSystemInfo({
				success: function(res) {
					let model = ['X', 'XR', 'XS', '11', '12', '13', '14', '15'];
					model.forEach(item => {
						//适配iphoneX以上的底部，给tabbar一定高度的padding-bottom
						if (res.model.indexOf(item) != -1 && res.model.indexOf('iPhone') != -1) {
							that.paddingBottomHeight = 40;
						}
					})
				}
			});


		},
		onLoad(ops) {
			uni.setStorageSync('sel_tags', null);

			uni.setStorageSync('sel_types', null);
			
			let pieces = []
			for(let i=1;i< 100; i++){
				pieces.push(i)
			}
			this.pieces = pieces
			
			if (ops.id) {
				// this.id = ops.id;
				this.form.id = ops.id;
				this.is_up = 1;
				this.getInfo();
			}

			if (ops.type) {
				this.id = ops.type;
				this.class_type = ops.type;
				this.type_name = ops.type_name
				this.form.type_name = ops.type_name
				this.form.type = ops.type;
			}
			
			
			let title = (ops.type && ops.type_name != '其他') ||  this.id ||  this.id == 0? '编辑橱窗' : '新建橱窗'
			if(this.id == 6){
				title = '新建橱窗'
			}
			this.title = title
			uni.setNavigationBarTitle({
				title: title
			})
		},
		onShow() {
			if (!this.$db.get('config') || this.$db.get('config') == null || this.$db.get('config') == undefined) {
				this.getConfig();
			}

			if (uni.getStorageSync('sel_tags')) {
				this.form.tags = uni.getStorageSync('sel_tags')
			}

			if (uni.getStorageSync('sel_types')) {
				this.form.type_class = uni.getStorageSync('sel_types')
			}

			this.getInit()
		},
		methods: {
			getInit(){
				this.$api.default.request('user/get_goods_list_type', {}, 'GET', false).then((res) => {
					if (res.code) {
						this.config = res.data
					}
				})
			},
			confirmSelect(){
				let sel;
				if(this.fees[0] == 0){
					sel = 10
				}else if(this.fees[0] == 1){
					sel = 100
				}else if(this.fees[0] == 2){
					sel = 1000
				}else if(this.fees[0] == 3){
					sel = 1000
				}
				
				let arr = this.config.filter(item => this.id == item.id)
				if(arr.length){
					let item = arr[0]
					
					if(Number(this.form.price)/Number(sel) < Number(item.mim_price)){
						this.form.price = ''
						this.$common.errorToShow(item.tit +'最低稿价 '+item.min_price_str)
						return
					}
				}
				
				
				this.showFee=false
				this.form.word_count=this.array[this.fees[0]]
			},
			checkNumber(e){
				this.form.price = parseInt(e.detail.value)
			},
			changePiece(e){
				this.dan = e.detail.value
			},
			changeFee(e){
				this.fees = e.detail.value
			},
			clickLeft(){
				if(this.isChanged){
					this.showConfirm=true
					return
				}
				
				uni.navigateBack()
			},
			checkContent(){
				this.form.price = parseInt(this.form.price)
				if(this.form.price < 1){
					this.$common.errorToShow('最小为1~')
					this.form.price = 1
				}
			},
			// 关闭须知弹窗
			close() {

			},
			// 开启须知弹窗
			open() {

			},
			// 删除图片
			deletePic(index) {
				this.isChanged = true
				this.form.img.splice(index, 1)
				this.fileList2.splice(index, 1)
			},
			onChooseImg() {
				let auth = db.get('auth');
				console.log(auth, 777777777)
				//用户存在，不跳转，不存在直接跳转
				if (!auth) {
					// toLogin()
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return;
				}
				this.$common.chooseImage({}, (data) => {
					if (data) {
						this.form.img.push(data)
					}
				}, 4)
			},
			// 新增图片
			async afterRead(event) {
				this.isChanged = true
				// 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this.form.img.length
				lists.map((item) => {
					this.form.img.push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise(lists[i].url,1)
					let item = this.form.img[fileListLen]
					this.form.img.splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: result
					}))
					fileListLen++
				}
			},
			// 新增图片
			async afterRead2(event) {
				this.isChanged = true
				// 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this.form.flair.length
				lists.map((item) => {
					this.form.flair.push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise2(lists[i].url,2)
					let item = this.form.flair[fileListLen]
					this.form.flair.splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: result
					}))
					fileListLen++
				}
			},
			// 新增图片
			async afterRead3(event) {
				this.isChanged = true
				// 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this.form.fullImg.length
				lists.map((item) => {
					this.form.fullImg.push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise3(lists[i].url,1)
					let item = this.form.fullImg[fileListLen]
					this.form.fullImg.splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: result
					}))
					fileListLen++
				}
			},
			uploadFilePromise3(url,type) {
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: this.uploadImgUrl, // 仅为示例，非真实的接口地址
						filePath: url,
						name: 'file',
						formData: {
							user: 'test'
						},
						success: (res) => {
							let datas = JSON.parse(res.data)
							this.fileList4.push(datas.url)
							
							setTimeout(() => {
								resolve(datas.url)
							}, 300)
						}
					});
				})
			},
			// 删除图片
			deletePic3(index) {
				this.isChanged = true
				this.form.fullImg = []
				this.fileList4= []
				this.$forceUpdate()
			},
			uploadFilePromise(url,type) {
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: this.uploadImgUrl, // 仅为示例，非真实的接口地址
						filePath: url,
						name: 'file',
						formData: {
							user: 'test'
						},
						success: (res) => {
							console.log(this.fileList2,123);
							let datas = JSON.parse(res.data)
							this.fileList2.push(datas.url)
							
							setTimeout(() => {
								resolve(datas.url)
							}, 300)
						}
					});
				})
			},
			uploadFilePromise2(url,type) {
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: this.uploadImgUrl, // 仅为示例，非真实的接口地址
						filePath: url,
						name: 'file',
						formData: {
							user: 'test'
						},
						success: (res) => {
							let datas = JSON.parse(res.data)
							this.fileList3.push(datas.url)
							
							setTimeout(() => {
								resolve(datas.url)
							}, 300)
						}
					});
				})
			},
			// 删除图片
			deletePic2(index) {
				this.isChanged = true
				this.form.flair.splice(index, 1)
				this.fileList3.splice(index, 1)
			},
			onChooseImg2() {
				let auth = db.get('auth');
				if (!auth) {
					uni.navigateTo({
						url: '/pages/login/login'
					})
					return;
				}
				this.$common.chooseImage({}, (data) => {
					if (data) {
						this.form.flair.push(data)
					}
				}, 4)
			},
			setdata(type) {
				
				this.type = type
				this.show = true;

			},
			setting() {
				this.isChanged = true
				this.show = false
				// var that = this
				// var prams = {
				// 	word_price: this.userInfo.writer_user_config.word_price,
				// 	word_count: this.userInfo.writer_user_config.word_count,
				// }

				// if (!prams['word_price']) {
				// 	this.$common.errorToShow('请输入价格', () => {
				// 		this.userInfo.writer_user_config.order_receiving_status = 0
				// 	}, 1000)
				// 	return
				// }

				// this.$api.default.request('user/saveWriterUserConfig', prams).then((res) => {
				// 	if (res.code == 1) {
				// 		that.$common.successToShow(res.msg, () => {
				// 			that.show = false
				// 		})
				// 	}
				// })

			},
			submit() {

				if (this.form.title == "") {
					this.$common.errorToShow('橱窗名称必填')
					return
				}

				if (this.form.desc == "") {
					this.$common.errorToShow('详情介绍必填')
					return
				}

				//tags
				if (this.form.sel_types == "" && this.form.type_name != "其他") {
					this.$common.errorToShow('最少要选择1个标签匹配')
					return
				}

				if (this.form.price < 1) {
					this.$common.errorToShow('价格需大于等于1')
					return
				}
				if (this.form.start_shooting < 1) {
					this.$common.errorToShow('起拍单数最少为1')
					return
				}
				if (this.form.img.length != 4) {
					this.$common.errorToShow('例文需要上传4张')
					return
				}
				
				if(this.form.flair.length != 4 && this.form.type_name == '法律文书'){
					this.$common.errorToShow('例文需要上传4张')
					return
				}
				
				let that = this;
				// #ifdef MP
					uni.requestSubscribeMessage({
					            //此处填写刚才申请模板的模板ID
						tmplIds: ['rw8um2woPZuyWmlZFrRYLslXmrIHd1MmcUTry7Ci3Yw'],
						success (res) {
							that.submit_end()
						},fail(err){
							
							that.submit_end()
						}
					})
				// #endif
				
				// #ifndef MP
					that.submit_end()
				// #endif

			},
			submit_end(){
				this.form.is_up = this.is_up;
				
				this.form.img = this.fileList2
				this.form.flair = this.fileList3
				
				this.$api.default.request('good/addGood_two', this.form, 'POST', false).then((res) => {
					if (res.code == 1) {
						this.$common.successToShow(res.msg, () => {
							
							if(uni.getStorageSync('sel_types')){
								uni.removeStorageSync('sel_types')
							}
							if(uni.getStorageSync('selectedItem')){
								uni.removeStorageSync('selectedItem')
							}
							if(uni.getStorageSync('list')){
								uni.removeStorageSync('list')
							}
							
							uni.navigateBack()
						})
					}
				})
			},
			getInfo() {
				this.$api.default.request('good/info', {
					id: this.form.id
				}).then((res) => {
					if (res.code && res.data) {
						this.form = res.data
						
						uni.setStorageSync('sel_tags', this.form.tags)
						//标签选择
						let imgs = res.data.img || []
						// this.fileList4 = imgs.slice(0,1)
						this.fileList2 = imgs
						this.fileList3 = res.data.flair || []
						
						// let img3 = this.fileList4
						// let imgArr3 = []
						// for(let i in img3){
						// 	imgArr3.push({
						// 		thumb: img3[i]
						// 	})
						// }
						// this.form.fullImg = imgArr3
						
						let img = this.fileList2
						let imgArr = []
						for(let i in img){
							imgArr.push({
								thumb: img[i]
							})
						}
						this.form.img = imgArr
						
						
						let img2 = res.data.flair || []
						let imgArr2 = []
						for(let i in img2){
							imgArr2.push({
								thumb: img2[i]
							})
						}
						this.form.flair = imgArr2
						
					}
				})
			},

			getUserInfo() {
				// this.$api.default.request('user/userInfo', {}, 'POST', false).then((res) => {
				// 	if (res.code) {
				// 		this.userInfo = res.user

				// 		this.userInfo.writer_user_config.word_count = this.userInfo.writer_user_config.word_count ?
				// 			this.userInfo.writer_user_config.word_count : this.array[0]
				// 		this.array.forEach((item, index) => {
				// 			if (res.user.writer_user_config.word_count == item) {
				// 				this.index = index
				// 			}
				// 		})
				// 	}
				// })
			},
			change(e) {
				this.xuan = !this.xuan
				this.submit()
			},
			// 弹框
			open() {

			},
			close() {
				this.show = false
			},
			// 字数
			bindPickerChange: function(e) {
				console.log('picker发送选择改变，携带值为', e.detail.value)
				this.index = e.detail.value

				this.form.word_count = this.array[e.detail.value]
			},
		}
	}
</script>

<style lang="scss" scoped>
	/deep/.u-upload{
		justify-content: flex-start;
		align-items: flex-start;
	}
	
	page {
		background: rgba(242, 245, 242, 1);
	}

	.content {
		/* #ifndef MP-WEIXIN */
		padding-top: calc(var(--status-bar-height) +  45px);
		/* #endif */

		.pjbox1 {
			width: 100%;
			height: 98rpx;
			background-color: #ffffff;
			display: flex;
			align-items: center;
			justify-content: center;
			position: fixed;
			left: 0;
			bottom: 0;

			view {
				float: left;
				width: 40%;
				height: 60rpx;
				line-height: 60rpx;
				margin: 0 auto;
				text-align: center;
				font-size: 24rpx;

				&:first-child {
					background: rgba(216, 216, 216, 0.3);
					color: #999;
				}

				&:last-child {
					background: rgba(216, 216, 216, 0.3);
					color: #fff;
					background: #45C4B0;
					border-radius: 4px;
				}
			}

		}






		.imgView {
			display: flex;
			align-items: center;
			flex-wrap: wrap;

			// .imgList:nth-child(3n){
			// 	margin-right: 0;
			// }
			.imgList {
				position: relative;
				padding-bottom: 10rpx;
				margin-right: 11rpx;

				.imgClose {
					position: absolute;
					top: -1px;
					right: -1px;
					z-index: 1;
					width: 26rpx;
					height: 26rpx;
				}
			}

			.imgList:first-child {
				margin-left: 0rpx;
			}
		}

		.baibox {
			background-color: #FFFFFF;
			padding: 0 30rpx;
			margin-bottom: 20rpx;

			.baili:last-child {
				border-bottom: none;
			}

			.other_wrap {
				flex-direction: column;
				align-items: initial !important;

				.item {
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: space-between;
				}

				.other_ipt {
					font-size: 14px;
					color: #3D3D3D;
				}

				.tip {
					font-size: 22rpx;
					font-weight: normal;
					color: #999999;
				}
			}

			.baili {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 40rpx 0;
				border-bottom: 1px solid rgba(153, 153, 153, 0.1);

				.other {
					font-size: 28rpx;
					font-weight: normal;
					color: #3D3D3D;
					padding-right: 60rpx;
				}

				.zhan {
					font-size: 28rpx;
					font-weight: bold;
					letter-spacing: 0em;
					color: #3D3D3D;
				}

				.left {
					flex-shrink: 0;

					.title {
						font-size: 28rpx;
						font-weight: bold;
						letter-spacing: 0em;
						color: #3D3D3D;
						padding-bottom: 0rpx;

						span {
							color: red;
							margin-left: 7rpx
						}

						.lw {
							font-size: 24rpx;
							color: #999;
							font-weight: 500;
						}
					}

					.txt {
						font-size: 24rpx;
						font-weight: normal;
						letter-spacing: 0em;
						color: #3D3D3D;
					}
				}

				.centxt {
					font-size: 28rpx;
					font-weight: normal;
					text-align: right;
					letter-spacing: 0em;
					color: #999999;
					width: 440rpx;
				}

				.cenbox {
					flex-grow: 1;
					display: flex;
					align-items: center;
					justify-content: flex-end;
					padding: 0 16rpx;

					.headpic {
						width: 80rpx;
						height: 80rpx;
						border-radius: 50%;
					}

					.centxt {
						font-size: 28rpx;
						font-weight: normal;
						text-align: right;
						letter-spacing: 0em;
						color: #999999;
						width: 440rpx;
					}

					.qianbox {
						text-align: right;
						width: 450rpx;
						white-space: nowrap;

						.qli {
							background: rgba(153, 153, 153, 0.1);
							padding: 3rpx 12rpx 4rpx 8rpx;
							border-radius: 178px;
							font-size: 24rpx;
							color: #3D3D3D;
							display: inline-block;
						}

						.qli:not(:first-child) {
							margin-left: 16rpx;
						}
					}
				}

				.rarr {
					width: 40rpx;
					height: 40rpx;
					flex-shrink: 0;
				}
			}
		}

		.ti {
			width: 630rpx;
			height: 86rpx;
			border-radius: 8px;
			line-height: 86rpx;
			margin: 0 auto;
			opacity: 1;
			background: #45C4B0;
			font-size: 32rpx;
			font-weight: bold;
			text-align: center;
			letter-spacing: 0em;
			color: #FFFFFF;
		}

		.mask {
			background-color: #FFFFFF;
			width: 500rpx;
			border-radius: 10px;
			padding-top: 30rpx;

			.jatitle {
				font-size: 28rpx;
				font-weight: bold;
				padding-bottom: 20rpx;
			}

			textarea {
				width: 90%;
				padding: 5%;
				font-size: 24rpx;
			}

			.japut {
				border-bottom: 1px solid #f2f2f2;
				font-size: 24rpx;
				color: #3D3D3D;
				padding-bottom: 15rpx;
				margin-bottom: 30rpx;
			}

			.qubox {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.quli {
					border-radius: 8px;
					border: 1px solid #eeeeee;
					font-size: 24rpx;
					color: #999999;
					width: 220rpx;
					text-align: center;
					height: 60rpx;
					line-height: 60rpx;
				}

				.que {
					border-radius: 8px;
					border: 1px solid #45C4B0;
					background-color: #45C4B0;
					font-size: 24rpx;
					color: #ffffff;
					text-align: center;
					width: 220rpx;
					height: 60rpx;
					line-height: 60rpx;
				}
			}
		}
	}

	// 认证提醒
	.tips_box {
		padding: 20rpx 30rpx;
		background: #E5FFFB;
		font-family: '思源黑体';
		font-size: 10px;
		color: #45C4B0;

		.tip_btn {
			margin-left: 25rpx;
			white-space: nowrap;
			padding: 2rpx 12rpx;
			border-radius: 126px;
			display: flex;
			align-items: center;
			justify-content: center;
			border: 1px solid #45C4B0;

		}
	}
	
	.tips_box2{
		padding: 20rpx 30rpx;
		background: #F2D8D6;
		font-family: '思源黑体';
		font-size: 10px;
		color: #ED3232;
	}

	// 认证须知弹窗
	.biaoqian {

		border-radius: 0.5em;
		background: #fff;
		width: 600rpx;
		margin: 0 auto;
		position: relative;

		.top {
			padding-top: 70rpx;
			font-size: 28rpx;
			color: #000;
			text-align: center;
			width: 90%;
			margin-left: 5%;

			image {
				width: 130rpx;
				height: 130rpx;
				position: absolute;
				left: 50%;
				transform: translateX(-50%);
				top: -35px;
				margin: 0 auto;
				border-radius: 20em;
			}

			.top_username {
				font-weight: 700;
				font-size: 16px;
				color: #3D3D3D;
			}

			view {
				&:last-child {
					margin-top: 6px;
					font-family: '思源黑体';
					font-size: 12px;
					color: #45C4B0;
				}
			}
		}

		.tab {
			padding-top: 10rpx;
			font-size: 21rpx;
			font-weight: 700;
			width: 90%;
			margin-left: 5%;
			float: left;
			text-align: center;
			font-family: '思源黑体';
			font-weight: 700;
			font-size: 14px;
			margin-top: 28rpx;
			margin-bottom: 28rpx;
		}

		.scroll {
			padding: 30rpx;
			padding-bottom: 20rpx;
			height: 520rpx;
			box-sizing: border-box;
			font-family: '思源黑体';
			font-size: 14px;
			color: #999;
			position: relative;
			overflow: hidden;
		}

		.white_mask {
			position: sticky;
			bottom: 0;
			left: 0;
			width: 100%;
			height: 80rpx;
			background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, .8));
		}

		.cont_t {
			border-radius: 8px;
			opacity: 1;
			background: #45C4B0;
			float: left;
			width: 80%;
			height: 86rpx;
			margin-left: 10%;
			margin-right: 10%;
			text-align: center;
			margin-top: 30rpx;
			color: #fff;
			line-height: 86rpx;

		}

		.cont_t_gray {
			background: #F2F5F2;
			color: #999;
		}
	}

	.cl1 {
		height: 60rpx;
		width: 60rpx;
		position: relative;
		top: 115rpx;
		left: 50%;
		transform: translateX(-50%);
	}
	
	.mask {
		background-color: #ffffff;
		width: 534rpx;
		border-radius: 8px;
		padding: 20rpx 30rpx;
	
		.matitle {
			font-size: 32rpx;
			font-weight: bold;
			text-align: center;
			letter-spacing: 0em;
			color: #3D3D3D;
			padding-bottom: 6rpx;
			line-height: 46rpx;
		}
	
		.matxt {
			font-size: 24rpx;
			font-weight: normal;
			text-align: center;
			letter-spacing: 0em;
			color: #999999;
			line-height: 34rpx;
			padding-bottom: 50rpx;
		}
	
		.quque {
			display: flex;
			align-items: center;
			border-top: 1px solid rgba(153, 153, 153, 0.1);
	
			.quli {
				width: 50%;
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				font-size: 32rpx;
				font-weight: normal;
				letter-spacing: 0em;
				color: #3D3D3D;
			}
	
			.quactive {
				background: rgba(69, 196, 176, 0.05);
			}
		}
	}
	
	.custom-bot2 {
		background-color: #FFFFFF;
		width: 750rpx;
		border-radius: 10px;
		text-align: center;
		
		.title{
			padding: 20px 0;
			font-family: '思源黑体';
			font-size: 14px;
			font-weight: bold;
			color: #3D3D3D;
		}
		
		.show-box{
			justify-content: center;
		}
	
		.picker-view {
			margin-left: 75rpx;
			width: 100rpx;
			height: 200rpx;
		}
		
		.inp-box{
			height: 34px;
			line-height: 34px;
			width: 300rpx;
			margin-right: 25rpx;
			border-top: 1px solid #eee;
			border-bottom: 1px solid #eee;
			color: #3D3D3D;
			font-family: '思源黑体';
			font-weight: bold;
			
			text{
				font-size: 15px;
				white-space: nowrap;
			}
		}
		
		input{
			height: 34px;
			line-height: 34px;
			font-size: 15px;
		}
	
		.item {
			height: 34px;
			line-height: 34px;
			font-family: '思源黑体';
			font-size: 15px;
			font-weight: bold;
			color: #3D3D3D;
		}
		
		.marginBorder{
			width: 100%;
			height: 10px;
			background: #F2F5F2;
		}
		
		.btn{
			margin: 10px auto;
			width: 80%;
			height: 40px;
			line-height: 40px;
			border-radius: 8px;
			background: #45C4B0;
			font-family: '思源黑体';
			font-size: 16px;
			font-weight: bold;
			color: #FFFFFF;
		}
	}
	
	.custom-bot {
		text-align: center;
		background-color: #fff;
		
		.title{
			padding: 20px 0;
			font-family: '思源黑体';
			font-size: 14px;
			font-weight: bold;
			color: #3D3D3D;
		}
	
		.picker-view {
			width: 750rpx;
			height: 200rpx;
		}
	
		.item {
			height: 34px;
			line-height: 34px;
			font-family: '思源黑体';
			font-size: 15px;
			font-weight: bold;
			color: #3D3D3D;
		}
		
		.marginBorder{
			width: 100%;
			height: 10px;
			background: #F2F5F2;
		}
		
		.btn{
			margin: 10px auto;
			width: 315px;
			height: 40px;
			line-height: 40px;
			border-radius: 8px;
			background: #45C4B0;
			font-family: '思源黑体';
			font-size: 16px;
			font-weight: bold;
			color: #FFFFFF;
		}
	}
</style>